﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BookMS
{
    public partial class user3 : Form
    {
        Model.lend m_lend = new Model.lend();
        BLL.Base table = new BLL.Base();
        public user3()
        {
            InitializeComponent();
        }
        private void user3_Load(object sender, EventArgs e)
        {
            Table();
        }
        //从数据库读取数据显示在表格控件中
        public void Table()
        {
            //string sql = $"select no,bid,jieshuriqi from lend where uid='{Data.UID}'";
            m_lend.uid = Data.UID;
            if (table.table(m_lend)!=null)
            {
                dataGridView1.DataSource = table.table(m_lend);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            m_lend.bid = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
            m_lend.no = Convert.ToInt32( dataGridView1.SelectedRows[0].Cells[0].Value.ToString());
            if(table.back(m_lend)>1)
            {
                MessageBox.Show("还书成功！");
                Table();
            }
        }
    }
}
